<?php

use Illuminate\Http\Request;

Route::get('/',function (){
    echo "登时科技后台Api";
});
Route::options('/{all}', function (Request $request) {
    $origin = $request->header('origin') ? $request->header('origin') : $request->header('referer');
    $allow_origin = [
        'http://localhost:9527','http://192.168.0.112:9527','http://polarisbar.com','http://www.polarisbar.com'
    ];
    if (in_array($origin, $allow_origin)) {
        header("Access-Control-Allow-Origin: $origin");
        header('Access-Control-Allow-Headers: Cache-Control, Transfer-Encoding, Connection, Origin, Content-Type, X-Token,Cookie, Accept, X-XSRF-TOKEN');
        header('Access-Control-Expose-Headers: *');
        header('Access-Control-Allow-Methods: *');
        header('Access-Control-Allow-Credentials: true');
    }
})->where(['all' => '([a-zA-Z0-9-_]|/)+']);
Route::group(['namespace' => 'Admin', 'middleware' => 'cors'],function(){
    Route::post('/upimg','Base@uploadImage');
    Route::post('/upimgs','Base@mutiUploadImg');
    Route::post('/login','Auth@userLogin'); //后台管理员登录
    Route::post('/logout','Auth@userLogout'); //后台管理员退出登录
    Route::get('/home','Base@index');
    Route::get('/adinfo','Auth@getAdminInfos')->middleware('customAuth'); //获取管理员信息（含权限）
    Route::group(['prefix'=>'auth','middleware' => 'customAuth'],function(){
        Route::post('/cremod','Auth@moduleCreate');//添加后台模块
        Route::post('/edtmod','Auth@moduleUpdate');//编辑后台模块
        Route::post('/crenav','Auth@navCreate');//添加后台菜单
        Route::post('/edtnav','Auth@navUpdate');//编辑后台菜单
        Route::post('/crepow','Auth@powerCreate');//添加后台权限
        Route::post('/edtpow','Auth@powerUpdate');//编辑后台权限
        Route::get('/modshow','Auth@moduleList');//获取模块列表
        Route::get('/navshow','Auth@navList');//获取模块列表
        Route::get('/powshow','Auth@powerList');//获取权限列表
    });

    Route::group(['prefix'=>'adtor','middleware' => 'customAuth'],function(){
        Route::post('/creadm','Adtor@registerAdmin');//添加后台管理员
        Route::post('/resetadm','Adtor@resetAdmin');//重置后台管理员密码
        Route::post('/edtadm','Adtor@adminUpdate');//编辑后台管理员
        Route::post('/admstatus','Adtor@changeAdmin');//禁用后台管理员
        Route::get('/admshow','Adtor@admList');//获取管理员列表
        Route::post('/crerole','Adtor@roleCreate');//添加角色
        Route::post('/edtrole','Adtor@roleUpdate');//编辑角色
        Route::get('/roleshow','Adtor@roleList');//获取角色列表
        Route::get('/navpow','Adtor@navPowers');//获取所有菜单及其权限列表
        Route::get('/rolepow','Adtor@rolePowers');//获取角色权限列表
    });

    Route::group(['prefix'=>'user','middleware' => 'customAuth'],function(){
        Route::post('/creuser','User@registerUser');//添加用户
        Route::post('/edtuser','User@userUpdate');//编辑用户
        Route::post('/userstatus','User@changeUser');//禁用用户
        Route::post('/impuser','User@importUser');//导入用户
        Route::post('/excuser','User@exportUser');//导出用户
        Route::get('/usershow','User@userList');//获取用户列表
        Route::post('/crelev','User@levCreate');//添加等级
        Route::post('/edtlev','User@levUpdate');//编辑等级
        Route::get('/levshow','User@levList');//获取等级列表

        Route::post('/recharge','User@rechargeUser');//用户充值
        Route::post('/withdraw','User@withdrawUser');//用户提现
        Route::post('/cagepay','User@changePayPass');//用户支付密码
        Route::post('/cagepass','User@changePassword');//用户登录密码

    });

    Route::group(['prefix'=>'prod','middleware' => 'customAuth'],function(){
        Route::post('/crecate','Prod@cateAdd');//添加商品分类
        Route::post('/edtcate','Prod@cateUpdate');//编辑商品分类
        Route::get('/cateshow','Prod@cateList');//获取商品分类列表
        Route::post('/creprod','Prod@prodAdd');//添加商品
        Route::post('/edtprod','Prod@prodUpdate');//编辑商品
        Route::post('/prodstatus','Prod@changeProd');//改变商品状态
        Route::get('/prodshow','Prod@prodList');//获取商品列表
        Route::post('/setprod','Prod@prodSetting');//设置商品等级折扣
        Route::get('/prosets','Prod@prodSets');//设置商品等级折扣
        Route::post('/setimgs','Prod@prodImages');//设置商品等级折扣

        Route::get('/jproshow','Prod@jifenProdList');//积分商品列表
        Route::post('/jprocre','Prod@jifenProdAdd');//积分商品添加
        Route::post('/jproedt','Prod@jifenProdUpdate');//积分商品编辑
        Route::post('/jproset','Prod@changeJifenProd');//积分商品状态改变
        Route::post('/jfenimgs','Prod@jifenProdImages');//设置积分商品图片
    });

    Route::group(['prefix'=>'dini','middleware' => 'customAuth'],function(){
        Route::post('/credin','Dini@dinAdd');//添加餐桌
        Route::post('/edtdin','Dini@dinUpdate');//编辑餐桌
        Route::get('/dinshow','Dini@dinList');//获取餐桌列表

        Route::get('/dorshow','Dini@dinOrderList');//获取餐桌预定列表
        Route::post('/credor','Dini@dinOrderAdd');//添加预定订单
        Route::post('/edtdor','Dini@dinOrderEdit');//编辑预定订单
        Route::post('/dorchk','Dini@dinOrderCheckOut');//预定订单发起结账
        Route::post('/dorsel','Dini@dinOrderSettle');//预定订单确认结账

        Route::post('/dorset','Dini@dinOrderChangeStatus');//更改预定订单状态
        Route::get('/dordetail','Dini@getDiningOrderDetail');//获取某个预定订单的详情
        Route::post('/credorp','Dini@addDinOrderProd');//添加预定订单的商品
        Route::post('/deldorp','Dini@delDinOrderProd');//退订预定订单的商品
        Route::post('/dopay','Dini@confirmPay'); //确认支付操作
        Route::post('/reford','Dini@refundDinOrd'); //预定订单退订
        Route::post('/store','Dini@dinOrderProdStore'); //餐桌预定订单商品存储

    });


    Route::group(['prefix'=>'img','middleware' => 'customAuth'],function(){
        Route::post('/edtimg','Img@imgUpdate');//编辑商品
        Route::post('/delimg','Img@deleteImg');//改变商品状态
        Route::get('/imgshow','Img@imgList');//获取商品列表

        Route::get('/lunboshow','Img@carouselList');//获取轮播图列表
        Route::post('/lunbocre','Img@carouselAdd');//添加轮播图
    });

    Route::group(['prefix'=>'order','middleware' => 'customAuth'],function(){
        Route::get('/ordshow','Order@orderList');//获取订单列表
        Route::post('/dopay','Order@confirmPay'); //确认支付操作
        Route::post('/reford','Order@refundOrder'); //预定订单退订
        Route::post('/ordsed','Order@orderSend');//订单发货

        Route::get('/jordshow','Order@orderJifenList');//获取积分商品列表
        Route::post('/jordsed','Order@jifenOrderSend');//积分订单发货
    });

    Route::group(['prefix'=>'cume','middleware' => 'customAuth'],function(){
        Route::get('/cumeshow','Cume@consumeList');//获取交易记录列表
        Route::get('/cageshow','Cume@rechargeList');//获取充值记录列表
        Route::post('/cageset','Cume@rechargeSet');//充值审核
        Route::get('/widrshow','Cume@withDrawList');//获取提现记录列表
        Route::post('/drawset','Cume@withdrawSet');//提现审核
        Route::get('/jfenshow','Cume@jifenList');//获取积分兑换记录
    });
    Route::group(['prefix'=>'set','middleware' => 'customAuth'],function(){
        Route::get('/infoshow','Set@sysInfos');//获取系统设置信息
        Route::post('/infoset','Set@infoSet');//设置系统信息
        Route::get('/bankshow','Set@bankList');//商家收款银行卡列表
        Route::post('/crebank','Set@bankCreate');//商家收款银行卡添加
        Route::post('/edtbank','Set@bankEdit');//商家收款银行卡编辑
        Route::post('/delbank','Set@bankDelete');//商家收款银行卡删除
    });
});
